package com.little.loan.controller;

import com.alibaba.fastjson.JSONObject;
import com.little.loan.entity.User;
import com.little.loan.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by 20259174 on 2018/2/8.
 */
@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    private final static Logger logger = LoggerFactory.getLogger(UserController.class);

    @RequestMapping(value="/getUser",method= RequestMethod.GET, produces="text/html;charset=UTF-8")
    @ResponseBody
    public String getUser(HttpServletRequest request, HttpServletResponse response){
        logger.debug("***********debug***********");
        logger.info("***********info***********");
        logger.error("************error***************");
        User user = userService.getUserById(1);
        JSONObject a = new JSONObject();
        a.put("data", user);
        logger.info(a.toJSONString());
        return a.toJSONString();
    }

}
